t
Prograph Development Styles

*73*The approach you take in Prograph application*69* development can be influenced by your personal preferences and whether or not you work in a development group that follows a prescribed work procedure. The next two sections of this tutorial demonstrate that Prograph is a viable development environment regardless of the approach you take in creating your applications.

If you put the styles of application development along a continuum, the end points would be anchored with structured analysis and requirements-based development at one end and dynamic, evolutionary*70* development at the other end. The structured approach is generally associated with a “top-down” strategy, while the evolutionary 
approach is associated with an “outside-in” or “look-to-feel” strategy.

The structured methodology begins with analysis and design. No code is written until the overall project is rigorously specified. Programmers often work on modules of a larger application with high-level dataflow diagrams and process-specification documents guiding their implementation.

The evolutionary approach is most often associated with creative, prototyping styles of development. Very often this dynamic strategy is used in research settings in which the goal of development is to explore new ideas, as in interface design. Since the objective is exploratory, no exact specification of the end result is provided as it is in the structured method. In the structured approach, no code is written until everything is specified. In the evolutionary approach, some code is written and interacted with. This leads to refinement and extension based on new insights, more code, and more interaction. 

More and more, the evolutionary approach is being adopted in commercial software development by those creative individuals or programming groups who have ideas for a “better mousetrap” and jump right into bringing them about. 

Although you may personally favor one approach or the other based upon the way in which you currently work, neither approach is all right or wrong, better or worse than the other. The structured and evolutionary styles each have appropriate uses. Very often, a combination of both styles is required to actually get the application put together.

As you read the next two sections of this tutorial, keep in mind how you wish to approach Prograph programming. If you fall more into one camp than the other, your usual approach will, of course, at first look better than any other. But, the facts are, both approaches to Prograph application development work for those who know and use them. And most of us fall somewhere between—using the method that is appropriate to the conditions and requirements of the task at hand.

t
Prograph Structured Development 

*72*If you are part of a development organization currently using a structured, analytic approach to application design and implementation, you already have a set of procedures that prescribe your development cycle. This section of the tutorial is not about to teach or to promote a specific approach to structured analysis. Rather, you should be able to see that Prograph fits well into such established development cycles.

As an example, take a brief look at a simple banking system presented in an article by*97* Sidney Bailin (“An Object-Oriented Requirements Specification Method,” Communications of the ACM, 32: 5, [May 1989], pp. 608-23). Bailin’s article makes a thoughtful case for reconciling structured analysis and design with object-oriented development. We’ll use Bailin’s argument and briefly show how high-level Entity Dataflow Diagrams (EDFD) can be implemented quickly and directly in Prograph’s visual environment.

In Bailin’s system, an external, real world customer interacts with the computerized banking system through keyed-in transactions (a 24-hour teller machine, for example) and by receiving mailed statements of his or her account.

The physical customer is modeled into the system as a customer object and the account is represented as another class of object. The labeled dataflow lines between the customer and account objects indicate the general categories of interaction that relate the customer and account within the system.

For purposes of this example, we focus on decomposition of the Account object as it relates to the flow of transactions from the customer. A second-level EDFD, following Bailin, further specifies the account object’s function.

Features of the Prograph development environment that facilitate the application of a structured-analysis-and-design approach include:

o
Prograph’s visual, dataflow method specification naturally maps onto high-level design specifications.

o
Prograph’s free-form text-comment facilities, especially the comment propagation feature, provide an unparalleled level of integrated system documentation encouraging consistency and reducing errors.

o
Prograph’s ability to nest method and local-method calls within method and local-method calls is directly applicable to functional decomposition techniques associated with structured-analysis-and-design methods.

o
Prograph’s ability to incorporate existing procedural-language modules, written in C, into Prograph as user-defined primitives allows Prograph to function as a high-level Computer Assisted Software Engineering (CASE)-type environment to organize and extend existing systems without rewriting tried and true code.

o
Prograph’s object-orientation and dataflow features provide a unique integration of object-oriented design and structured-analysis methodologies, an area of intense research interest that other environments are having difficulty reconciling.

How would a programmer implement Bailin’s banking system in Prograph? A first cut at this implementation involves creation of the required classes. Attributes of the new Customer and Account classes are defined. In addition, two Window subclasses are created to provide the user interface to allow customer-transaction entry and account-manager statement production.

Next, closer inspection of the decomposition of the Account EDFD suggests some initial methods.

Analyzing the 2.1 Update Account node of the EDFD diagram, some assumptions are made about the internal specification of the Update Account method.

o
Its input-bar root delivers either a customer transaction event or another bank’s forwarding of a customer’s check event.

o
The method updates attribute information related to the account of the customer who initiates the transaction or whose check has come in.

o
If the transaction causes an overdraft, the bad-check chain of events is initiated.

If this simple banking system were to be further decomposed, the tasks that make up the high-level Update Account node would be specified, giving a third and more deeply nested view into the updating procedure for accounts. In the screen shots below, you see local methods are used to encapsulate collections of subtasks that occur during the update.

Notice that an extensive, multiline comment has been used on each method’s input bar to provide a complete project-identification and implementation record including important dates and approval sign-offs. In addition, EDFD numerical node identifiers have been placed on each operation in the Prograph methods.

This example is not intended to be comprehensive or fully presented. Rather, it is to give you a sense of how Prograph and its flexible environment can be appropriately used in a structured-design-and-analysis method of large application development.

If this is the style of development you or your group uses, you will have no trouble finding ways to incorporate Prograph into your existing procedures. However, if you want to use Prograph in a more organic style of programming, continue on to the next section.

t
Prograph Evolutionary Development

*71*More and more programming today is being done by individuals. The lone programmer pursues an entrepreneurial dream of writing the next great revolutionary piece of commercial software. Many pursue independent projects as part of academic, industrial, or commercial research. Others program simply for the joy and self-development of it.

If you fit into one of these categories, you will find much to like about Prograph, as it supports the style of programming we earlier characterized as dynamic evolutionary development. The primary general characteristic of the editor/interpreter environment supporting this fluid style of application development is Prograph’s seamless integration.

Seamless integration means that you are free to do what needs to be done when it needs to be done. *874*You are not locked into a rigid set of procedures that can stifle creativity and reduce productivity.*928* 

Typical programming environments are highly modal, in Macintosh terms. That is, you have to do one thing at a time, moving from editing to compiling to running to debugging, and so on. If you make a change, you have to cycle through a sequence of time-consuming steps to see the result of your change.

As you have already experienced, Prograph is extremely flexible in letting you create and edit aspects of your application on-the-fly, evolving your application by stepping easily back and forth from your application environment to the Prograph editors. In the Grand Tour of Application Builder (chapter 3) you specified a click method for a button and were greeted by this dialog:

as you interacted with your fledgling application by clicking the Add button. 

And you have created a new method simply by making a calling operation with the new method’s name within the case window of an existing method. Double-clicking on the left side of this operation creates the new method and opens its case window with input and output comments propagating to the new method.

This dynamic creation of instances and methods is complemented by the on-the-fly creation of persistents as well as new classes and their attributes. When used in combination with Application Builder, you have the unique ability to shape and reshape a complex interface and underlying computations without exiting and rerunning your application.

u
Open the System Classes file to start with a fresh Application Builder environment.

u
Enter the Application editor and name your new application Gizmo Maker.

u
This example application does not require any menus, but it is good form to supply at least a minimal menu bar. The System Classes file comes with a minimal File menu with a single item named Quit with a /Quit method and a Q command-key equivalent. Together with the default Apple menu, this gives you bare-bones menuing for the Gizmo Maker application.

u
Add a Window instance that looks like this to your application:

u
Set the Make button’s click method to /Make. The lower right side Window Item instance is a Scroll Text instance that you should name Gizmo Display. (Note this item is not a Scroll List like you put in your Folks Database window.) Be sure to click the Wrap check box in the Scroll Text editor. The New Gizmo Specs label is a simple, unnamed Text item. Don’t forget to add this window to the Active List so it is visible when you execute your application.

u
Press OK to dismiss the Application editor, and then execute your application.

u
Click the Make button and press Return twice to indicate that you do want to create the new Make method in class Window. When the Make method execution window pops up, open its case window and edit it to look like this:

u
Open a case window on the make Gizmo local method and edit it to look like this:

u
Activate the Make execution window and press Return to start stepping through the new method’s operations. When the make Gizmo local method is ready to execute, press Shift-Return to pop down into this local’s execution window.

u
Due to Prograph’s inherent concurrency, there is no way to know the exact order in which execution will attempt to create the Gizmo class, the Gizmo Inventory persistent, and the Gizmo attributes thingamabob and part#. So:

 • When prompted by a dialog that asks if you want to create a new Gizmo class, press Return to accept the default OK response.

 • When prompted by a dialog that asks if you want to create a new Gizmo Inventory persistent, press Return to accept the default OK response. Immediately, the Value of Persistent Gizmo Inventory pops up with a NULL current value. Scroll the Data Types list upward and click on the list item to prepare the inventory to store a list of Gizmo instances in inventory.

 • When the Ask primitive is executed, it pops up a dialog. Press OK to accept the default text chrome.

 • As both the Get and Set operations are executed, press Return to indicate you want to create these attributes in class Gizmo. Press Return to accept the default Instance selection at the dialog that asks for the type of the new attribute. Press Return at the Value of Attribute thingamabob to leave its default value at NULL. But at the Value of Attribute part#, enter 900-9 and press Return, as all Gizmo instances are assigned this number. (You may have noticed that the use of a Get operation on the part# attribute does not serve any useful purpose in this example. The point was for you to see that dynamic attribute-creation works for both Set and Get operations.)

u
Continue pressing Return to step all the way through the make Gizmo local and Make method. As the Make method’s execution concludes, the Gizmo Maker window’s Scroll Text item is updated to show that you have just created a new Gizmo instance, part number 900-9, with a chrome thingamabob! Pretty remarkable when you consider that you started with nothing more than the shell of a window that could not do anything useful before you made it happen—all on the fly while your application was running.

This dynamic creation of instances, methods, persistents, and even classes and their attributes in conjunction with Application Builder allows you to develop elaborate user interfaces and complex applications quickly and easily.

Features of the Prograph development environment that encourage this dynamic evolutionary approach to application development include:

o
Prograph’s seamless integration of concurrent execution of your developing application and Prograph’s editors stimulate creativity and productivity, since your programming can keep up with the flow of your ideas.

o
Application Builder’s built-in event-loop processing lets you keep your creative energy focused on the things you are trying to get your application to do. You don’t get bogged down in the obscure technical implementation of the Macintosh Toolbox and operating-system facilities.

o
The Application editor’s Set Defaults button makes it easy to define the default values of attributes of a new subclass by using an existing instance of its superclass as a template.

o
Prograph dynamically creates new instances, methods, and classes as you execute your application. This allows you to move your initial development forward by creating only the things your application needs to run at its current level of development. Without this feature, you can find yourself guessing, creating classes and methods you think you will need, only to find that you don’t need them after all. 

o
Selective and incremental loading encourage productive reuse and sharing of classes and methods developed for other applications. You don’t waste thought and energy reinventing.

As you see from the list above, dynamic, creative, evolutionary development by an individual or small group is largely facilitated by features that increase productivity. A programming environment that works with you is the primary tool in getting the job done. 

As you gain more experience with Prograph and Application Builder, you probably will evolve your own list of Prograph benefits. This personal list of benefits will be greatly affected by the style of Prograph programming you develop. The goal of these last few sections of this tutorial has been to demonstrate that Prograph has a wide range of features to fit your style, whatever it may be.

t
Check Your Progress

*0150*Congratulations on completing this chapter. Once learned, Application Builder is a powerful tool for the rapid development of Macintosh applications. It is, however, a rich collection of facilities that may be completely new to most programmers.

The effort you put into understanding Application Builder and its System classes will be repaid by painless, productive Prograph programming.

In this tutorial, you have learned:

4 how to use Prograph’s Application Builder to by-pass tedious, error-prone low-level Macintosh programming

4 about the structure and function of the Prograph System Classes and how they are used in the Application Builder

4 how Prograph enhances your application development productivity for structured as well as evolutionary-development styles of programming.

If you still feel a little unsure about some topics covered in this tutorial, review the material and skim relevant portions of the Reference manual. We also strongly urge you to take a look at some of the examples provided on the Prograph distribution disks; in particular, the files in the Learning Prograph folder are very useful to beginning Prographers. The Simple Examples file contains methods that illustrate Prograph controls, loops, primitives and general tips and techniques on the language itself. The SysClass Examples file contains examples of how to work with each of the supplied System Classes, including creating a draw method for a Canvas using Macintosh Toolbox calls.